package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.EcologyHatchExtraRewardsConfig;
import com.sc.nft.entity.EcologyHatchExtraRewardsMethodConf;
import com.sc.nft.entity.EcologyHatchMethodConf;
import com.sc.nft.mapper.EcologyHatchExtraRewardsMethodConfMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author Radish
 * @Description:
 * @date 2024-11-26
 */
@Slf4j
@Repository
public class EcologyHatchExtraRewardsMethodConfDao  extends ServiceImpl<EcologyHatchExtraRewardsMethodConfMapper, EcologyHatchExtraRewardsMethodConf> {


    public boolean updateById(Long id, BigDecimal probability) {
        LambdaUpdateWrapper<EcologyHatchExtraRewardsMethodConf> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(EcologyHatchExtraRewardsMethodConf::getId, id);
        wrapper.set(EcologyHatchExtraRewardsMethodConf::getProbability, probability);

        return update(new EcologyHatchExtraRewardsMethodConf(), wrapper);
    }


    /**
     * 根据熔炼配置id获取列表
     *
     * @param ecologyHatchId
     * @return
     */
    public List<EcologyHatchExtraRewardsMethodConf> findListByEcologyHatchId(Long ecologyHatchId) {
        LambdaQueryWrapper<EcologyHatchExtraRewardsMethodConf> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(EcologyHatchExtraRewardsMethodConf::getEcologyHatchId, ecologyHatchId);
        return baseMapper.selectList(queryWrapper);
    }

    public List<EcologyHatchExtraRewardsMethodConf> listByExtraRewardsId(Long extraRewardsId) {
        LambdaQueryWrapper<EcologyHatchExtraRewardsMethodConf> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(EcologyHatchExtraRewardsMethodConf::getExtraRewardsId, extraRewardsId);
        return list(queryWrapper);
    }

    public List<EcologyHatchExtraRewardsMethodConf> findAll() {
        LambdaQueryWrapper<EcologyHatchExtraRewardsMethodConf> queryWrapper = Wrappers.lambdaQuery();
        return baseMapper.selectList(queryWrapper);
    }

}
